package com.alphaking.controller.admin;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alphaking.model.Category;
import com.alphaking.pojo.common.ReturnResult;
import com.alphaking.service.mingweicai.BlogService;

@Controller
public class AdminFindCategoryController {
	
	@Resource
	private BlogService blogService;	
	/**
	 * 找到下级分类
	 * 
	 * @param parentId
	 *            一级分类的id
	 * @return
	 * @throws SecurityException 
	 * @throws NoSuchFieldException 
	 */
	@RequestMapping("/admin/findCategorysByParentId")
	@ResponseBody
	public ReturnResult<List<Category>> findCategorys(String parentId) 
			throws NoSuchFieldException, SecurityException {
		
		List<Category> productCategories = 
				this.blogService.getPriorityCategory(parentId);
		ReturnResult<List<Category>> returnResult = new ReturnResult<>();
		returnResult.setCode(0);
		returnResult.setData(productCategories);
		returnResult.setRetMsg("获取成功");
		return returnResult ;
		
	}
	


}
